//
//  BDHomeTableViewCell.m
//  BadBoy
//
//  Created by wen on 2017/3/13.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDHomeTableViewCell.h"
#import "BDHomeCellImageview.h"
#import "BDHomeCellMerchantsView.h"
#import "BDHomeCellForwardingView.h"
#import "UIButton+WebCache.h"
#import "BDHomeCellBottomView.h"
#import "BDTextLabel.h"
#import "BDUserModel.h"
#import "PopoverView.h"
#import "BDTextFieldAlert.h"
#import "BDFMDBTool.h"
@interface BDHomeTableViewCell ()
{
    BOOL isOpen;
    NSString *_post;
}
//第一列内容
@property (nonatomic, strong) UIButton *avatarImageView;
@property (nonatomic, strong) UILabel *nicknameLabel;
@property (nonatomic, strong) UIImageView *levelImageView;
@property (nonatomic, strong) UILabel *createAtLabel;
@property (nonatomic, strong) UILabel *typeLabel;
@property (nonatomic, strong) UIButton *moreButton;
@property (nonatomic, strong) UIButton *quanwenButton;
@property (nonatomic, strong) UIImageView *vipImageView;
//文本内容
@property (nonatomic, strong) BDTextLabel *contentTextLabel;
//九宫图
@property (nonatomic, strong) BDHomeCellImageview *imageContentView;
//转发
@property (nonatomic, strong) BDHomeCellForwardingView *forwardContentView;
//付费
@property (nonatomic, strong) BDHomeCellMerchantsView *merchantContentView;
//底下功能栏
@property (nonatomic, strong) BDHomeCellBottomView *bottomView;

@property (nonatomic, copy) void(^avatarblock)();
@property (nonatomic, copy) void(^allblock)();

@property (nonatomic, strong) BDHomeModel *model;
@end

@implementation BDHomeTableViewCell


- (void)configeWithModel:(BDHomeModel *)model avatarBlock:(void(^)())avatarBlock allButtonBlock:(void(^)())allButtonBlock zanBlock:(void(^)(UIButton *button))zanBlock forwardBlock:(void(^)())forwardBlock pinglunBlock:(void(^)())pinglunBlock sharedBlock:(void(^)())sharedBlock merchantsBlock:(void(^)())merchantsBlock imageClickBlock:(void(^)(NSInteger index, NSArray *imagesArray, UIView *clickView))imageClickBlock{
    
    
    [self.avatarImageView sd_setBackgroundImageWithURL:[NSURL URLWithString:model.user.cover] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"avatar"]];
    
    self.nicknameLabel.text = model.user.nickname;
    
    self.levelImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"leve%ld",[model.points[@"level"] integerValue]]];
    
    self.vipImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", [NSString stringWithFormat:@"showVip%ld",model.user.vip_level]]];
    if (model.user.vip_level != 0) {
        self.vipImageView.hidden = NO;
    }else{
        self.vipImageView.hidden = YES;
    }
    
    NSDate *curDate = [NSDate dateWithTimeIntervalSince1970:model.created_at.floatValue];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM-dd"];
    NSString *dateStr = [formatter stringFromDate:curDate];
    self.createAtLabel.text = dateStr;
    _post = model.post;
    [self.imageContentView configeWithModel:model];
    [self.forwardContentView configeWithModel:model];
    [self.merchantContentView configeWithModel:model];
    [self.bottomView configeWithZanState:model.praise
                                     zan:[NSString stringWithFormat:@"%@", @(model.praiseCount)]
                                 message:[NSString stringWithFormat:@"%@", @(model.commentCount)]
                                 forword:[NSString stringWithFormat:@"%@", @(model.repostCount)]
                                  shared:[NSString stringWithFormat:@"%@", @(model.sharedCount)]];
    self.model = model;
    self.avatarblock = avatarBlock;
    self.allblock = allButtonBlock;
    self.bottomView.zanBlock = zanBlock;
    self.bottomView.forwardBlock = forwardBlock;
    self.bottomView.pinglunBlock = pinglunBlock;
    self.bottomView.sharedBlock = sharedBlock;
    self.merchantContentView.merchantsBlock = merchantsBlock;
    self.imageContentView.imageClickBlock = imageClickBlock;
    self.forwardContentView.imageViews.imageClickBlock = imageClickBlock;
    
//    BDUserModel *user = [BDUserModel getCurrentUser];
//    if (user.user_id == model.user.user_id || user.user_id == model.user_id) {
//        self.moreButton.hidden = YES;
//    }else{
//        self.moreButton.hidden = NO;
//    }
    self.typeLabel.text = [self getTypeStringWithType:model.category];
}

- (NSString *)getTypeStringWithType:(NSInteger)type{
    if (type == 1) {
        return ASLocalizedString(@"#水疗");
    }else if (type == 2) {
        return @"#KTV";
    }else if (type == 3) {
        return ASLocalizedString(@"#夜总会");
    }else if (type == 4) {
        return ASLocalizedString(@"#酒吧");
    }else if (type == 5) {
        return ASLocalizedString(@"#沐足");
    }
    return ASLocalizedString(@"#其他");
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.avatarImageView.frame = CGRectMake(10, 7, 40, 40);
    _avatarImageView.layer.masksToBounds = YES;
    _avatarImageView.layer.cornerRadius = 20;
    
    self.moreButton.frame = CGRectMake(kBDScreenWidth - 40, 5, 30, 30);
    
    self.typeLabel.textColor = KBDColorBlue;
    self.typeLabel.font = [UIFont systemFontOfSize:12];
    [self.typeLabel sizeToFit];
    self.typeLabel.right = self.moreButton.left - 15;
    self.typeLabel.centerY = self.moreButton.centerY;
    
    self.nicknameLabel.textColor = [UIColor colorWithHexString:@"#1c1c1c"];
    self.nicknameLabel.font = [UIFont systemFontOfSize:14];
    [self.nicknameLabel sizeToFit];
    self.nicknameLabel.top = 12;
    self.nicknameLabel.left = self.avatarImageView.right + 5;
    
    self.levelImageView.size = CGSizeMake(22 / 2, 26 / 2);
    self.levelImageView.left = _nicknameLabel.right + 5;
    self.levelImageView.centerY = _nicknameLabel.centerY;
    
    self.vipImageView.size = CGSizeMake(34 / 2, 25 / 2);
    self.vipImageView.centerY = self.levelImageView.centerY;
    self.vipImageView.left = self.levelImageView.right + 5;
    
    self.createAtLabel.font = [UIFont systemFontOfSize:10];
    self.createAtLabel.textColor = [UIColor colorWithHexString:@"#767676"];
    self.createAtLabel.size = CGSizeMake(self.width - self.avatarImageView.right, 11);
    self.createAtLabel.top = self.nicknameLabel.bottom + 5;
    self.createAtLabel.left = self.nicknameLabel.left;
    
    self.contentTextLabel.numberOfLines = 0;
    self.contentTextLabel.textColor = [UIColor colorWithHexString:@"#1c1c1c"];
    self.contentTextLabel.width = self.width - 20;
    self.contentTextLabel.lineBreakMode = NSLineBreakByWordWrapping;
    self.contentTextLabel.left = 10;
    self.contentTextLabel.top = self.avatarImageView.bottom + 8;
    self.contentTextLabel.textAlignment = NSTextAlignmentLeft;
    NSMutableAttributedString *one = [[NSMutableAttributedString alloc] initWithString:[_post isNotEmpty] ? _post : @""];
    one.lineSpacing = 5;
    one.font = [UIFont systemFontOfSize:15];
    self.contentTextLabel.attributedText = one;
    
    self.contentTextLabel.height = self.model.contentHeight;
//    // BDLog(ASLocalizedString(@"自适应之前的高度：%.2f"), self.model.contentHeight);
    [self.contentTextLabel sizeToFit];
//    // BDLog(ASLocalizedString(@"自适应之后的高度：%.2f"), self.contentTextLabel.height);
    
    CGFloat top = self.contentTextLabel.bottom + 10;
    
    if (self.model.needOpen && self.model.isDetail == NO) {
        self.quanwenButton.hidden = NO;
        self.quanwenButton.left = 10;
        self.quanwenButton.top = self.contentTextLabel.bottom + 5;
        top = self.quanwenButton.bottom + 5;
        self.quanwenButton.selected = self.model.isOpen;
    }else{
        self.quanwenButton.hidden = YES;
    }
    
    NSMutableArray *arr = [NSMutableArray array];
    NSMutableArray *hei = [NSMutableArray array];
    if (self.model.images.count != 0) {
        self.imageContentView.hidden = NO;
        [arr addObject:self.imageContentView];
        [hei addObject:@(self.model.imageHeight)];
    }else{
        self.imageContentView.hidden = YES;
    }
    
    //显示为删除，这里需要控制
//    if (self.model.repost != nil && (self.model.repost.is_public == NO || self.model.repost.status == 1)) {
//        self.forwardContentView.hidden = YES;
//        self.merchantContentView.hidden = NO;
//    }else{
        if (self.model.repost != nil) {
            self.forwardContentView.hidden = NO;
            [arr addObject:self.forwardContentView];
            [hei addObject:@(self.model.forwardHeight)];
        }else{
            self.forwardContentView.hidden = YES;
        }
        
        //首先是在detail内，而且有meracten，然后没有购买
        if (self.model.isDetail == YES) {
            if (self.model.haveMeracten == YES && self.model.isPurchase == NO && self.model.price != 0) {
                self.merchantContentView.hidden = NO;
            }else {
                self.merchantContentView.hidden = YES;
            }
        }else {
            if (self.model.haveMeracten == NO) {
                self.merchantContentView.hidden = YES;
            }else{
                self.merchantContentView.hidden = NO;
            }
        }
        
        if (self.model.isDetail == YES) {
            self.bottomView.hidden = YES;
        }else {
            self.bottomView.hidden = NO;
        }
//    }
    
    if (self.merchantContentView.hidden == NO) {
        [arr addObject:self.merchantContentView];
        [hei addObject:@(self.model.merachantHeight)];
    }
    
    for (int i = 0; i < arr.count; i++) {
        BDHomeCellContentView *contentView = arr[i];
        CGFloat contentHeight = [hei[i] floatValue];
        contentView.width = self.width;
        contentView.height = contentHeight;
        contentView.top = top;
        if (contentHeight != 0) {
            top = contentView.bottom + 10;
        }
    }
    
    self.bottomView.size = CGSizeMake(kBDScreenWidth, 36);
    self.bottomView.top = top;
    
    if (self.model.isDetail == NO) {
        self.height = self.bottomView.bottom;
    }
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)quanwenButtonAction:(UIButton *)button{
    // BDLog(ASLocalizedString(@"点击了查看全文"));
    if (self.allblock) {
        self.allblock();
    }
}

- (void)avataraction{
    self.avatarblock();
}

- (void)moreButtonAction:(UIButton *)moreButton{
    PopoverAction *addFriAction = [PopoverAction actionWithTitle:ASLocalizedString(@"加好友")handler:^(PopoverAction *action) {
        [BDUserModel judgeCurrentUserWithNormalBlock:^{
            [BDTextFieldAlert showWithTitle:ASLocalizedString(@"添加好友")placeHolder:ASLocalizedString(@"打个招呼吧")finishBlock:^(NSString *text) {
                NSInteger userId = self.model.user.user_id != 0 ? self.model.user.user_id : self.model.user_id;
//                EMError *error = [[EMClient sharedClient].contactManager addContact:[NSString stringWithFormat:@"%@", @(userId)] message:text];
//                if (!error) {
//                    [MBManager showBriefAlert:ASLocalizedString(@"请求已发送")clickHidden:NO clickBlock:nil];
//                }
            }];
        }];
    }];
    NSString *guanzhuTitle = self.model.is_follow == YES ? ASLocalizedString(@"取消关注"): ASLocalizedString(@"关注");
    PopoverAction *QRAction = [PopoverAction actionWithTitle:guanzhuTitle handler:^(PopoverAction *action) {
        [BDUserModel judgeCurrentUserWithNormalBlock:^{
            NSInteger guanzhuUserId = self.model.user.user_id != 0 ? self.model.user.user_id : self.model.user_id;
            NSString *url = [NSString stringWithFormat:@"%@follow/%@", KBDBaseURL, @(guanzhuUserId)];
            NSString *headValid = [BDUserModel getHeaderValidation];
            //        NSDictionary *para = @{@"id":@(self.model.my_id)};
            [MBManager showLoadingAlert:ASLocalizedString(@"请稍后")clickHidden:NO clickBlock:nil];
            RACSignal *signal = [[BDNetworkingServer yy_POST:url parameters:nil validation:headValid automaticProcessingError:YES] execute:nil];
            [signal subscribeNext:^(id  _Nullable x) {
//                [MBManager hideAlert];
                [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"%@成功"), guanzhuTitle] clickHidden:NO clickBlock:nil];
                self.model.is_follow = [x[@"status"] boolValue];
                //发送给首页的，当关注人变更之后，首页关注列表也要跟着变更
                [[NSNotificationCenter defaultCenter] postNotificationName:@"guanzhuChange" object:nil];
            }];
            
            [signal subscribeError:^(NSError * _Nullable error) {
//                [MBManager hideAlert];
                [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"%@失败"), guanzhuTitle] clickHidden:NO clickBlock:nil];
                // BDLog(ASLocalizedString(@"关注操作失败：%@"), error);
            }];
        }];
    }];
    NSString *shoucangTitle = self.model.fav == YES ? ASLocalizedString(@"取消收藏"): ASLocalizedString(@"收藏");
    PopoverAction *facetofaceAction = [PopoverAction actionWithTitle:shoucangTitle handler:^(PopoverAction *action) {
        [BDUserModel judgeCurrentUserWithNormalBlock:^{
            NSString *url = [NSString stringWithFormat:@"%@post/%@/fav", KBDBaseURL, @(self.model.my_id)];
            NSString *headValid = [BDUserModel getHeaderValidation];
            NSDictionary *para = @{@"id":@(self.model.my_id)};
            [MBManager showLoadingAlert:ASLocalizedString(@"请稍后")clickHidden:NO clickBlock:nil];
            RACSignal *signal = [[BDNetworkingServer yy_POST:url parameters:para validation:headValid automaticProcessingError:YES] execute:nil];
            [signal subscribeNext:^(id  _Nullable x) {
//                [MBManager hideAlert];
                [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"%@成功"), shoucangTitle] clickHidden:NO clickBlock:nil];
                self.model.fav = [x[@"status"] boolValue];
            }];
            
            [signal subscribeError:^(NSError * _Nullable error) {
//                [MBManager hideAlert];
                [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"%@失败"), shoucangTitle] clickHidden:NO clickBlock:nil];
                // BDLog(ASLocalizedString(@"收藏失败：%@"), error);
            }];
        }];
    }];
    PopoverView *popoverView = [PopoverView popoverView];
    
    PopoverAction *blackListAction = [PopoverAction actionWithTitle:ASLocalizedString(@"加入黑名单")handler:^(PopoverAction *action) {
        [BDUserModel judgeCurrentUserWithNormalBlock:^{
            NSString *url = [NSString stringWithFormat:@"%@blackList/%@", KBDBaseURL, @(self.model.user.user_id)];
            NSString *headValid = [BDUserModel getHeaderValidation];
            NSDictionary *para = @{@"id":@(self.model.user.user_id)};
            [MBManager showLoadingAlert:ASLocalizedString(@"请稍后")clickHidden:NO clickBlock:nil];
            RACSignal *signal = [[BDNetworkingServer yy_POST:url parameters:para validation:headValid automaticProcessingError:YES] execute:nil];
            [signal subscribeNext:^(id  _Nullable x) {
//                [MBManager hideAlert];
                [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"加入黑名单成功")] clickHidden:NO clickBlock:nil];
                [[NSNotificationCenter defaultCenter] postNotificationName:@"blackListChange" object:nil];
            }];
            
            [signal subscribeError:^(NSError * _Nullable error) {
//                [MBManager hideAlert];
                [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"加入黑名单失败")] clickHidden:NO clickBlock:nil];
            }];
        }];
    }];
    
    PopoverAction *jubaoAction = [PopoverAction actionWithTitle:ASLocalizedString(@"举报")handler:^(PopoverAction *action) {
        NSString *url = [NSString stringWithFormat:@"%@post/%@/report", KBDBaseURL, @(self.model.my_id)];
        NSString *headValid = [BDUserModel getHeaderValidation];
        NSDictionary *para = @{@"id":@(self.model.my_id)};
        [MBManager showLoadingAlert:ASLocalizedString(@"请稍后")clickHidden:NO clickBlock:nil];
        RACSignal *signal = [[BDNetworkingServer yy_POST:url parameters:para validation:headValid automaticProcessingError:YES] execute:nil];
        [signal subscribeNext:^(id  _Nullable x) {
//            [MBManager hideAlert];
            [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"举报成功")] clickHidden:NO clickBlock:nil];
        }];
        
        [signal subscribeError:^(NSError * _Nullable error) {
//            [MBManager hideAlert];
            [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"举报失败")] clickHidden:NO clickBlock:nil];
        }];
    }];
    
    NSString *freezStirng = self.model.isFreez ? ASLocalizedString(@"解冻"): ASLocalizedString(@"冻结");
    PopoverAction *freezAction = [PopoverAction actionWithTitle:freezStirng handler:^(PopoverAction *action) {
        NSString *url = [NSString stringWithFormat:@"%@posts/%@", KBDBaseURL, @(self.model.my_id)];
        NSString *headValid = [BDUserModel getHeaderValidation];
        NSDictionary *para = @{@"id":@(self.model.my_id)};
        [MBManager showLoadingAlert:ASLocalizedString(@"请稍后")clickHidden:NO clickBlock:nil];
        RACSignal *signal = [[BDNetworkingServer yy_DELETE:url parameters:para validation:headValid automaticProcessingError:YES] execute:nil];
        [signal subscribeNext:^(id  _Nullable x) {
//            [MBManager hideAlert];
            [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"%@成功"), freezStirng] clickHidden:NO clickBlock:nil];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"deletedPost" object:self.model];
        }];
        
        [signal subscribeError:^(NSError * _Nullable error) {
//            [MBManager hideAlert];
            [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"%@失败"), freezStirng] clickHidden:NO clickBlock:nil];
        }];
    }];
    
    NSString *pingbiString = self.model.is_public ? ASLocalizedString(@"屏蔽"): ASLocalizedString(@"取消屏蔽");
    PopoverAction *pingbiAction = [PopoverAction actionWithTitle:pingbiString handler:^(PopoverAction *action) {
        NSString *url = [NSString stringWithFormat:@"%@posts/%@/public", KBDBaseURL, @(self.model.my_id)];
        NSString *headValid = [BDUserModel getHeaderValidation];
        [MBManager showLoadingAlert:ASLocalizedString(@"请稍后")clickHidden:NO clickBlock:nil];
        RACSignal *signal = [[BDNetworkingServer yy_PUT:url parameters:nil validation:headValid automaticProcessingError:YES] execute:nil];
        [signal subscribeNext:^(id  _Nullable x) {
//            [MBManager hideAlert];
            [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"%@成功"), pingbiString] clickHidden:NO clickBlock:nil];
            self.model.is_public = [x[@"is_public"] integerValue];
            //这里还要考虑在屏蔽成功之后的一些操作
            [[NSNotificationCenter defaultCenter] postNotificationName:@"pingbiAction" object:self.model];
        }];
        [signal subscribeError:^(NSError * _Nullable error) {
//            [MBManager hideAlert];
            [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"%@失败"), pingbiString] clickHidden:NO clickBlock:nil];
        }];
    }];
    
    PopoverAction *deletedAction = [PopoverAction actionWithTitle:ASLocalizedString(@"删除")handler:^(PopoverAction *action) {
        NSString *url = [NSString stringWithFormat:@"%@posts/%@", KBDBaseURL, @(self.model.my_id)];
        NSString *headValid = [BDUserModel getHeaderValidation];
        NSDictionary *para = @{@"id":@(self.model.my_id)};
        [MBManager showLoadingAlert:ASLocalizedString(@"请稍后")clickHidden:NO clickBlock:nil];
        RACSignal *signal = [[BDNetworkingServer yy_DELETE:url parameters:para validation:headValid automaticProcessingError:YES] execute:nil];
        [signal subscribeNext:^(id  _Nullable x) {
//            [MBManager hideAlert];
            [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"删除成功")] clickHidden:NO clickBlock:nil];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"deletedPost" object:self.model];
//            [[NSNotificationCenter defaultCenter] postNotificationName:@"blackListChange" object:nil];
            
        }];
        
        [signal subscribeError:^(NSError * _Nullable error) {
//            [MBManager hideAlert];
            [MBManager showBriefAlert:[NSString stringWithFormat:ASLocalizedString(@"删除失败")] clickHidden:NO clickBlock:nil];
        }];
    }];
    
    
    BOOL needAdd = YES;
    
//    NSArray *firends = [BDFMDBTool queryWithClass:[BDFridentInfo class]];
//    for (BDFridentInfo *friend in firends) {
//        if (self.model.user_id == friend.user_id.integerValue || self.model.user.user_id == friend.user_id.integerValue) {
//            needAdd = NO;
//            break;
//        }
//    }
    
    NSMutableArray *actionsArray = nil;
    
    BDUserModel *user = [BDUserModel getCurrentUser];
    if (user.user_id == self.model.user.user_id) {
        actionsArray = @[deletedAction].mutableCopy;
    }else{
        if (needAdd == YES) {
            actionsArray = @[addFriAction].mutableCopy;
        }else{
            actionsArray = [NSMutableArray array];
        }
        [actionsArray addObjectsFromArray:@[QRAction, facetofaceAction, blackListAction, jubaoAction]];
        
        
        if (user.is_admin == YES) {
            [actionsArray addObject:freezAction];
            [actionsArray addObject:pingbiAction];
        }
    }
    
    [popoverView showToView:moreButton withActions:actionsArray];
}

- (UIButton *)avatarImageView{
    if (!_avatarImageView) {
        self.avatarImageView = [[UIButton alloc] init];
        [_avatarImageView addTarget:self action:@selector(avataraction) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_avatarImageView];
    }
    return _avatarImageView;
}

- (UILabel *)nicknameLabel{
    if (!_nicknameLabel) {
        self.nicknameLabel = [[UILabel alloc] init];
//        _nicknameLabel.adjustsFontForContentSizeCategory= YES;
        [self.contentView addSubview:_nicknameLabel];
    }
    return _nicknameLabel;
}

-(UIImageView *)levelImageView{
    if (!_levelImageView) {
        self.levelImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_levelImageView];
    }
    return _levelImageView;
}


- (UILabel *)createAtLabel{
    if (!_createAtLabel) {
        self.createAtLabel = [[UILabel alloc] init];
//        _createAtLabel.adjustsFontForContentSizeCategory= YES;
        [self.contentView addSubview:_createAtLabel];
    }
    return _createAtLabel;
}

- (UIImageView *)vipImageView{
    if (!_vipImageView) {
        self.vipImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_vipImageView];
    }
    return _vipImageView;
}

- (BDTextLabel *)contentTextLabel{
    if (!_contentTextLabel) {
        self.contentTextLabel = [[BDTextLabel alloc] init];
//        _contentTextLabel.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:_contentTextLabel];
    }
    return _contentTextLabel;
}

- (UIButton *)moreButton{
    if (!_moreButton) {
        self.moreButton = [[UIButton alloc]init];
        [_moreButton setImage:[UIImage imageNamed:@"xia_2"] forState:UIControlStateNormal];
        [_moreButton addTarget:self action:@selector(moreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_moreButton];
    }
    return _moreButton;
}

- (UILabel *)typeLabel{
    if (!_typeLabel) {
        self.typeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_typeLabel];
    }
    return _typeLabel;
}

- (UIButton *)quanwenButton{
    if (!_quanwenButton) {
        self.quanwenButton = [[UIButton alloc]init];
        [_quanwenButton setTitle:ASLocalizedString(@"全文")forState:UIControlStateNormal];
        [_quanwenButton setTitle:ASLocalizedString(@"收起")forState:UIControlStateSelected];
        [_quanwenButton setTitleColor:KBDColorBlue forState:UIControlStateNormal];
        _quanwenButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _quanwenButton.size = CGSizeMake([[_quanwenButton titleForState:UIControlStateNormal] widthWithFont:_quanwenButton.titleLabel.font], _quanwenButton.titleLabel.font.pointSize + 10);
        [self.contentView addSubview:_quanwenButton];
        [_quanwenButton addTarget:self action:@selector(quanwenButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _quanwenButton;
}

- (BDHomeCellImageview *)imageContentView{
    if (!_imageContentView) {
        self.imageContentView = [[BDHomeCellImageview alloc] init];
//        _imageContentView.backgroundColor = [UIColor purpleColor];
        [self.contentView addSubview:_imageContentView];
    }
    return _imageContentView;
}

- (BDHomeCellForwardingView *)forwardContentView{
    if (!_forwardContentView) {
        self.forwardContentView = [[BDHomeCellForwardingView alloc] init];
//        _forwardContentView.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_forwardContentView];
    }
    return _forwardContentView;
}

- (BDHomeCellMerchantsView *)merchantContentView{
    if (!_merchantContentView) {
        self.merchantContentView = [[BDHomeCellMerchantsView alloc] init];
//        _merchantContentView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_merchantContentView];
    }
    return _merchantContentView;
}

- (BDHomeCellBottomView *)bottomView{
    if (!_bottomView) {
        self.bottomView = [[BDHomeCellBottomView alloc] init];
        [self.contentView addSubview:_bottomView];
    }
    return _bottomView;
}

@end
